C code for getting and setting formulas

The following code demonstrates the use of PEGetFormula to retrieve the text of a named formula and PESetFormula to change the text of a named formula:

PEGetFormula

HANDLE        textHandle;
short        textLength;
char        *formulaString; char formulaName [] = "MyFormula"; if (!PEGetFormula(Job, formulaName, &textHandle, &textLength)){
    // Handle error
}     // Allocate formulaString buffer
formulaString = (char*)malloc(textLength);     // Retrieve actual formula string
if (!PEGetHandleString(textHandle, formulaString, textLength)){
    // Handle error
}     // formulaString now contains text of named formula

PESetFormula

char formulaName [] = "MyFormula";
char formulaString [] = "{salesrep.SALES} * .10";
    // 10% commission if (!PESetFormula(Job, formulaName, formulaString)){
    // Handle error
}


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com